package com.icw.utility.query;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class PageCount {

	public PageCount(int length) {
		this.length = length;
	}

	public PageCount(int pageNo, int length) {
		this(length);
		this.pageNo = pageNo;
	}

	private Integer pageNo = 1;

	private Integer length = 10;

	private Integer count = 0;

	private Integer start = null;

	public Integer getStart() {
		if (start != null) {
			return start;
		} else if (pageNo != null) {
			return (pageNo - 1) * length;
		} else {
			return 0;
		}
	}

	public Integer getTotalPage() {
		return Math.max(1, count / length + (count % length == 0 ? 0 : 1));
	}
}